<?php

/**
 * 
 * 
 *
 */
class Quad_Profiler {

	protected static $_instances;
	protected $_enabled;
	protected $_startTime;
	protected $_times;
	
	public static function getInstance($name='') {
		
	}
	
	public function __construct($name='') {
		register_shutdown_function(array($this, 'writeToLog'));
		self::$_instances[] = array($name, $this);
	}
	
	public function enable() {
		$this->_enabled = true;
		return $this;
	}
	
	public function disable() {
		$this->_enabled = false;
		return $this;
	}
	
	public function isEnabled() {
		return $this->_enabled;
	}
	
	public function start() {
		if ($this->_enabled) {
			$this->_startTime = microtime(true);
		}
		return $this;
	}
	
	public function end($data=null) {
		if ($this->_enabled) {
			$time = $this->_addTime($this->_startTime, microtime(true), $data);
			unset($this->_startTime);
			return $time;
		}
		return false;
	}
	
	protected function _addTime($start, $end, $data) {
		$seconds = $end - $start;
		$this->_times[] = array(
			'start' => $start,
			'end' => $end,
			'seconds' => $seconds,
			'data' => $data
		);
		return $seconds;
	}
	
	public static function writeToLog() {
		if ($this->_enabled) {
			
		}
	}
  
}